/// <reference path="../../../../typings/index.d.ts" />
import util from '../../../common/js/util'
import NProgress from 'nprogress'
import axios from 'axios';
import address from "../../../../models/dict/address.js"  //任务字典模块
import moment from 'moment'

import task from "../../../../models/dict/task.js"  //任务字典模块
import array from "../../../../models/comm/array.js"  //数组操作模块
import yz from "../../../../models/comm/yz.js"  //数组操作模块
import Vue from 'vue'

import math from 'mathjs';

import clType from '../../../../models/dict/clothesSizeType'



export default {
    data() {
        return {



            unitArray: task.unitArray(),

            listLoading: false,
            amount: 0,

            sizeIdArray: [

                "10", "20", "30"

            ]


        }
    },
    methods: {


        addDetail() {
            var item = task.fmtDetailItem({}, this.currObj.taskClassId);



            this.sizeIdArray.forEach(function (sizeId) {

                item[sizeId] = 0
            }, this);




            this.currObj.detail.push(item)

            this.fmtDetal();
        },

        fmtTask: function () {


            task.fmtTask(this.currObj);
        },
        delDetal(row, index) {


            this.currObj.detail.splice(index, 1);
        },
        fmtDetal() {

            // debugger
            // this.sizeIdArray = yz.IsNullThen(this.customerOrder[this.currObj.flowClassId].sizeIdArray, [])


            var list = [];

            this.currObj.detail.forEach(function (item) {
                var item2 = {};
                // this.sizeIdArray.forEach(function (sizeId) {



                //     if (item[sizeId]) {
                //         item2[sizeId] = item[sizeId]
                //     }
                //     else {
                //         item2[sizeId] = 0
                //     }




                // }, this);
                item2.taskClassId = item.taskClassId
                item2.part = item.part
                item2.dangRange = item.dangRange
                item2.errorRange = item.errorRange
                item2.method = item.method
                item2.memo = item.memo
                item2.createTime = item.createTime
                item2 = task.fmtDetailItem(item2, "300")
                list.push(item2)
            }, this);

            this.currObj.detail = list
        },
        getSizeName(sizeId) {
            return clType.getSizeName(sizeId)

        }




    },
    props: ["currObj", "customerOrder", "taskId"],
    mounted() {

        console.log('t300被创建了');
        this.fmtDetal();
    },
    watch: {
        "currObj._id": function () {

            console.log('t300中改变了currObj._id');

            this.fmtDetal();

        }

    }
}